/**
 * 行程订单流转操作
 *
 */
define(["app", "comm/pager/PagerControl", "js/services/MessageBox", "js/services/MuseService"], function (app) {

    var deps = ["$scope", "$state", "$modal", "MessageBox", "MuseService", '$modalInstance', 'request'];

    function controller ($scope, $state, $modal, MessageBox, MuseService, $modalInstance, request) {
        $scope.request = request;

        $scope.close = function () {
            $modalInstance.dismiss();
        };

        /**
         * 确认是否流转
         * @param targettripActivity
         */
        $scope.faild = function () {

            if (isEmpty($scope.reason)) {
                MessageBox.error("拒绝理由不能为空");
                return;
            }

            var param = {
                id: $scope.request.id,
                reason: $scope.reason
            }

            MuseService.post(baseServices_restfulUrl + 'withdrawDepositRequest/faild.json', param).success(
                function (data) {
                    if (data.state == 0) {
                        MessageBox.notify({msg: '拒绝成功！', displayTime: 1000});
                        $modalInstance.close("faildSuccess");
                    } else {
                        MessageBox.error('拒绝错误：' + data.message || "服务器正在开小差");
                    }
                })
            .error(function () {
                MessageBox.error('拒绝错误：服务器正在开小差');
            });
        }

    }

    controller.$inject = deps;
    app.lazy.controller("FaildSubmitController", controller);
});
